package com.ruoyi.screen.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.screen.domain.DeviceFile;
import com.ruoyi.screen.service.IDeviceFileService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 设备播放素材Controller
 * 
 * @author ruoyi
 * @date 2025-06-05
 */
@RestController
@RequestMapping("/devicefile")
public class DeviceFileController extends BaseController
{
    @Autowired
    private IDeviceFileService deviceFileService;

    /**
     * 所有设备播放素材列表
     */
    @RequiresPermissions("screen:devicefile:list")
    @GetMapping("/allList")
    public AjaxResult allList()
    {
        DeviceFile deviceFile = new DeviceFile();
        List<DeviceFile> list = deviceFileService.selectDeviceFileList(deviceFile);
        return success(list);
    }
    /**
     * 查询设备播放素材列表
     */
    @RequiresPermissions("screen:devicefile:list")
    @GetMapping("/list")
    public TableDataInfo list(DeviceFile deviceFile)
    {
        startPage();
        List<DeviceFile> list = deviceFileService.selectDeviceFileList(deviceFile);
        return getDataTable(list);
    }

    /**
     * 导出设备播放素材列表
     */
    @RequiresPermissions("screen:devicefile:export")
    @Log(title = "设备播放素材", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceFile deviceFile)
    {
        List<DeviceFile> list = deviceFileService.selectDeviceFileList(deviceFile);
        ExcelUtil<DeviceFile> util = new ExcelUtil<DeviceFile>(DeviceFile.class);
        util.exportExcel(response, list, "设备播放素材数据");
    }

    /**
     * 获取设备播放素材详细信息
     */
    @RequiresPermissions("screen:devicefile:query")
    @GetMapping(value = "/{deviceFileId}")
    public AjaxResult getInfo(@PathVariable("deviceFileId") Long deviceFileId)
    {
        return success(deviceFileService.selectDeviceFileByDeviceFileId(deviceFileId));
    }

    /**
     * 新增设备播放素材
     */
    @RequiresPermissions("screen:devicefile:add")
    @Log(title = "设备播放素材", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceFile deviceFile)
    {
        return toAjax(deviceFileService.insertDeviceFile(deviceFile));
    }

    /**
     * 修改设备播放素材
     */
    @RequiresPermissions("screen:devicefile:edit")
    @Log(title = "设备播放素材", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceFile deviceFile)
    {
        return toAjax(deviceFileService.updateDeviceFile(deviceFile));
    }

    /**
     * 删除设备播放素材
     */
    @RequiresPermissions("screen:devicefile:remove")
    @Log(title = "设备播放素材", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceFileIds}")
    public AjaxResult remove(@PathVariable Long[] deviceFileIds)
    {
        return toAjax(deviceFileService.deleteDeviceFileByDeviceFileIds(deviceFileIds));
    }
}
